<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var subsetsWithDup = function (nums) {
        nums.sort((a, b) => a - b)
        let res = []
        let map = new Map()
        function backTracking(path, start) {
          if (start > nums.length) return
          let str = path.join('')
          if (!map.has(str)) {
            map.set(str, 1)
            res.push([...path])
          }
          for (let i = start; i < nums.length; i++) {
            path.push(nums[i])
            backTracking(path, i + 1)
            path.pop()
          }
        }
        backTracking([], 0)
        return res
      }
    </script>
  </body>
</html>
